import axios from 'axios'
import http from '../utils/requestUtil'

//登录
export function login(username: any, password: any) {
  return http({
    url: '/auth/login',
    method: 'POST',
    data: {
      username,
      password
    }
  })
}

/**
 * 获取当前用户id
 * @returns 
 */
export function getUserId() {
  return http({
    url: '/friend/getUserId',
    method: 'GET',
  })
}

/**
 * 获取用户角色
 * @returns 
 */
export function getUserRole(userId: any) {
  return http({
    url: '/friend/getUserRole',
    method: 'GET',
    params: {
      userId
    }
  })
}

/**
 * 获取当前用户角色
 * @returns 
 */
export function getCurrentUserRole() {
  return http({
    url: '/friend/getCurrentUserRole',
    method: 'GET',
  })
}

/**
 * 添加博客
 * @param blog 
 * @returns 
 */
export function addBlog(blog: any) {
  return http(
    {
      url: '/blog/addBlog',
      method: 'POST',
      data: blog,
      headers:{
         'ConContent-Type': "application/json",
      },
    }
  )
}


/**
 * 展示当前用户文章
 * @param bloggerId 
 * @returns 
 */
export function listArticle(bloggerId: any) {
    return http(
      {
        url: '/blog/getBlogByUser',
        method:'GET',
        params: { bloggerId},
        headers: {
          'ConContent-Type': "application/json",
        },
      }
    )
}


/**
 * 展示书签
 * @param bloggerId 
 * @returns 
 */
export function listBookmark(userId: any) {
  return http(
    {
      url: '/blog/getBookmarkByUser',
      method: 'GET',
      params: { userId },
      headers:{
         'ConContent-Type': "application/json",
      },
    }
  )
}

/**
 * 根据id查询博文
 * @param id 
 * @returns 
 */
export function listBlogById(id: any) {
  return http(
    {
      url: '/blog/getBlogById',
      method: 'GET',
      params: { id },
      headers:{
         'ConContent-Type': "application/json",
      },
    }
  )
}

/**
 * 展示草稿
 * @param bloggerId 
 * @returns 
 */
export function listDraft(bloggerId: any) {
  return http(
    {
      url: '/blog/getBlogByUser',
      method: 'GET',
      params: { bloggerId },
      headers:{
         'ConContent-Type': "application/json",
      },
    }
  )
}

/**
 * 根据博文id查询博文信息
 * @param id 
 * @returns 
 */
export function showBlogContent(id: any) {
  return http(
    {
      url: '/blog/getBlogById',
      method: 'GET',
      params: { id },
      headers:{
         'ConContent-Type': "application/json",
      },
    }
  )
}

/**
 * 点赞博文
 * @param id 
 * @returns 
 */
export function likesBlog(id: any) {
  return http(
    {
      url: '/blog/likeBlog',
      method: 'GET',
      params: { id },
      headers:{
         'ConContent-Type': "application/json",
      },
    }
  )
}


/**
 * 根据id查找用户
 * @param id 
 * @returns 
 */
export function getUserById(userId: any) {
  return http(
    {
      url: '/friend/getUserBaseLimitedInfo',
      method: 'GET',
      params: { userId },
      headers:{
         'ConContent-Type': "application/json",
      },
    }
  )
}

/**
 * 获取博文评论
 * @param blogId 
 * @returns 
 */
export function getBlogComment(blogId: any) {
  return http(
    {
      url: '/blog/getCommentList',
      method: 'GET',
      params: { blogId },
      headers:{
         'ConContent-Type': "application/json",
      },
    }
  )
}

/**
 * 根据评论id获取评论回复
 * @param commentId 
 * @returns 
 */
export function getReply(commentId: any) {
  return http(
    {
      url: '/blog/getReplyByComment',
      method: 'GET',
      params: { commentId },
      headers:{
         'ConContent-Type': "application/json",
      },
    }
  )
}

/**
 * 新增评论
 * @param comment 
 * @returns 
 */
export function commitComment(comment: any) {
  return http(
    {
      url: '/blog/addComment',
      method: 'POST',
      data: comment,
      headers:{
         'ConContent-Type': "application/json",
      },
    }
  )
}

/**
 * 新增回复
 * @param reply 
 * @returns 
 */
export function commitCommentReply(reply: any) {
  return http(
    {
      url: '/blog/addReply',
      method: 'POST',
      data: reply,
      headers:{
         'ConContent-Type': "application/json",
      },
    }
  )
}

/**
 * 点赞评论
 * @param id 
 * @returns 
 */
export function likesComment(id: any) {
  return http(
    {
      url: '/blog/likeComment',
      method: 'GET',
      params: {
        id,
      },
      headers:{
         'ConContent-Type': "application/json",
      },
    }
  )
}

/**
 * 点赞回复
 * @param id 
 * @returns 
 */
export function likesReply(id: any) {
  return http(
    {
      url: '/blog/likeReply',
      method: 'GET',
      params: {
        id,
      },
      headers:{
         'ConContent-Type': "application/json",
      },
    }
  )
}

/**
 * 删除评论
 * @param id 
 * @returns 
 */
export function deletesComment(id: any) {
  return http(
    {
      url: '/blog/deleteComment',
      method: 'GET',
      params: {
        id,
      },
      headers:{
         'ConContent-Type': "application/json",
      },
    }
  )
}

/**
 * 删除回复
 * @param id 
 * @returns 
 */
export function deletesReply(id: any) {
  return http(
    {
      url: '/blog/deleteReply',
      method: 'GET',
      params: {
        id,
      },
      headers:{
         'ConContent-Type': "application/json",
      },
    }
  )
}

/**
 * 添加书签
 * @param bookmark 
 * @returns 
 */
export function addBookmark(bookmark: any) {
  return http(
    {
      url: '/blog/addBookmark',
      method: 'POST',
      data: bookmark,
      headers:{
         'ConContent-Type': "application/json",
      },
    }
  )
}

/**
 * 删除书签
 * @param bookmark 
 * @returns 
 */
export function deleteBookmark(bookmark: any) {
  return http(
    {
      url: '/blog/deleteBookmark',
      method: 'GET',
      params: bookmark,
      headers:{
         'ConContent-Type': "application/json",
      },
    }
  )
}

/**
 * 删除博客
 * @param blog 
 * @returns 
 */
export function deleteBlog(id: any) {
  return http(
    {
      url: '/blog/deleteBlog',
      method: 'GET',
      params: {id},
      headers:{
         'ConContent-Type': "application/json",
      },
    }
  )
}

/**
 * 更新博客
 * @param blog 
 * @returns 
 */
export function updateBlog(blog: any) {
  return http(
    {
      url: '/blog/updateBlog',
      method: 'POST',
      data: blog,
      headers:{
         'ConContent-Type': "application/json",
      },
    }
  )
}

/**
 * 根据标题查找博客
 * @param info 
 * @returns 
 */
export function getBlogByTitle(info: any) {
  return http(
    {
      url: '/blog/getBlogByTitle',
      method: 'GET',
      params: {info},
      headers:{
         'ConContent-Type': "application/json",
      },
    }
  )
}

/**
 * 根据内容查找博客
 * @param info 
 * @returns 
 */
export function getBlogByContent(info: any) {
  return http(
    {
      url: '/blog/getBlogByContent',
      method: 'GET',
      params: {info},
      headers:{
         'ConContent-Type': "application/json",
      },
    }
  )
}

/**
 * 根据博文状态查询博文
 * @param status 
 * @returns 
 */
export function getBlogByStatus(status: any) {
  return http(
    {
      url: '/blog/getBlogByStatus',
      method: 'GET',
      params: {status},
      headers:{
         'ConContent-Type': "application/json",
      },
    }
  )
}


/**
 * 获取热门博文
 * @returns 
 */
export function getHotBlog() {
  return http(
    {
      url: '/blog/getBlogByLikes',
      method: 'GET',
      headers:{
         'ConContent-Type': "application/json",
      },
    }
  )
}